import request from "@/utils/request";

/**
 * 获取订单列表
 * @param { getOrderList } data
 */
export const getOrderList = data => {
  return request({
    url: "/mall/tenant/merchant/order/getOrderList",
    method: "post",
    data
  });
};
/**
 * 查询关联客户
 * @param { customAddress } data
 */
export const customAddress = search => {
  return request({
    url: `/mall/tenant/merchant/order/customAddress?search=${search}`,
    method: "get"
  });
};
/**
 * 获取客户关联地址
 * @param { relationCustomerAddress } data
 */
export const relationCustomerAddress = data => {
  return request({
    url: "/mall/tenant/merchant/order/relationCustomerAddress",
    method: "post",
    data
  });
};

/* 导入sku
 * @param { relationCustomerAddress } data
 */
export const importExcel = data => {
  return request({
    url: "/mall/tenant/merchant/order/excel/import",
    method: "post",
    data
  });
};
/* 下载sku
 * @param { templateDownload } data
 */
export const templateDownload = data => {
  return request({
    url: "/mall/tenant/merchant/order/template/download",
    method: "post",
    responseType: "blob",
    data
  });
};
/* 生成订单
 * @param { createOrder } data
 */
export const createOrder = data => {
  return request({
    url: "/mall/tenant/merchant/order/createOrder",
    method: "post",
    data
  });
};
/* 修改订单状态
 * @param { updateOrderStatus } data
 */
export const updateOrderStatus = data => {
  return request({
    url: "/mall/tenant/merchant/order/updateOrderStatus",
    method: "post",
    data
  });
};
/* 修改订单地址和备注
 * @param { updateOrderInfo } data
 */
export const updateOrderInfo = data => {
  return request({
    url: "/mall/tenant/merchant/order/updateOrderInfo",
    method: "post",
    data
  });
};
/* 订单详情
 * @param { getOrderDetail } data
 */
export const getOrderDetail = (orderId, orderNo) => {
  return request({
    // url: `/mall/tenant/merchant/order/getOrderDetail?orderId=${orderId}`,
    url: `/mall/tenant/merchant/order/getOrderDetail/new?orderId=${orderId}&orderNo=${orderNo}`,
    method: "get"
  });
};
/* 修改订单价格
 * @param { updateOrderPrice } data
 */
export const updateOrderPrice = data => {
  return request({
    url: "/mall/tenant/merchant/order/updateOrderPrice",
    method: "post",
    data
  });
};
/* 获取客户收货地址列表
 * @param { getCustomerAddressList } data
 */
export const getCustomerAddressList = customerId => {
  return request({
    url: `/mall/tenant/merchant/order/getCustomerAddressList?customerId=${customerId}`,
    method: "get"
  });
};
/* 13.删除收货地址（根据id）
 * @param { deleteCustomerAddress } data
 */
export const deleteCustomerAddress = data => {
  return request({
    url: "/mall/tenant/merchant/order/deleteCustomerAddress",
    method: "post",
    data
  });
};

/* 13保存客户收货地址信息
 * @param { saveCustomerAddress } data
 */
export const saveCustomerAddress = data => {
  return request({
    url: "/mall/tenant/merchant/order/saveCustomerAddress",
    method: "post",
    data
  });
};
/* 关闭订单
 * @param { closeOrder } data
 */
export const closeOrder = data => {
  return request({
    url: "/mall/tenant/merchant/order/closeOrder",
    method: "post",
    data
  });
};

/* 删除订单某一商品
 * @param { deleteOrderSku } data
 */
export const deleteOrderSku = data => {
  return request({
    url: "/mall/tenant/merchant/order/deleteOrderSku",
    method: "post",
    data
  });
};

/* 创建采购单
 * @param { createPurchase } data
 */
export const createPurchase = data => {
  return request({
    url: "/mall/tenant/merchant/order/createPurchase",
    method: "post",
    data
  });
};
/* 创建采购单
 * @param { createPurchase } data
 */
export const createMeasureOrder = data => {
  return request({
    url: "/mall/tenant/merchant/measureOrder/createMeasureOrder",
    method: "post",
    data
  });
};

/* 创建定时采购单
 * @param { createTimingPurchase } data
 */
export const createTimingPurchase = data => {
  return request({
    url: "/mall/tenant/merchant/order/createTimingPurchase",
    method: "post",
    data
  });
};
/* 删除定时采购
 * @param { delTimingPurchase }
 */
export const delTimingPurchase = data => {
  return request({
    url: "/mall/tenant/merchant/order/delTimingPurchase",
    method: "post",
    data
  });
};
/* 删除订单
 * @param { delOrder }
 */
export const delOrder = data => {
  return request({
    url: "/mall/tenant/merchant/order/delOrder",
    method: "post",
    data
  });
};
/* 修改定时采购单
 * @param { updateTimingPurchase }
 */
export const updateTimingPurchase = data => {
  return request({
    url: "/mall/tenant/merchant/order/updateTimingPurchase",
    method: "post",
    data
  });
};

/* 上传
 * @param { uploadFile }
 */
export const uploadFile = data => {
  return request({
    url: "/mall/tenant/merchant/order/excel/import",
    method: "post",
    data
  });
};
/* 19.锁定列表查询
 * @param { getLockList }
 */
export const getLockList = (orderId, factoryId) => {
  return request({
    url: `/mall/tenant/merchant/order/${orderId}/${factoryId}/lock-list`,
    method: "get"
  });
};
/* 19.20.锁定页面保存修改接口
 * @param { updateLock }
 */
export const updateLock = data => {
  return request({
    url: "/mall/tenant/merchant/order/update-lock",
    method: "put",
    data
  });
};

/**
 *获取支付账号列表
 */
export const getPayAccountList = data => {
  return request({
    url: "/mall/tenant/merchant/order/getPayAccountList",
    method: "post",
    data
  });
};

export const getPayInfo = orderId => {
  return request({
    url: `/mall/tenant/merchant/order/getPayInfo/${orderId}`,
    method: "get"
  });
};

/**
 *获取预计发货时间信息
 */
export const getShipmentDaysByProducts = data => {
  return request({
    url: "/mall/tenant/merchant/order/getShipmentDaysByProducts",
    method: "post",
    data
  });
};
